package com.sopt.view;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.content.Intent;
import android.text.format.DateUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.sopt.friends.ChatActivity;
import com.sopt.friends.R;
import com.sopt.friends.statics.FriendsStaticVars;
import com.sopt.friends.sub.FreshActivity;
import com.sopt.friends.vo.FriendsChat;
import com.sopt.friends.vo.FriendsChatRoom;
import com.sopt.friends.vo.FriendsCommonItem;

public class ChatRoomListAdapter extends BaseAdapter{
	public Context mContext;
	public List<FriendsChatRoom> mMemberList;
	public int mLayout;
	
	public ChatRoomListAdapter(Context context, int layout, List<FriendsChatRoom> inputList) {
		mContext = context;
		mMemberList = inputList;
		mLayout = layout;
	}

	public int getCount() {
		return mMemberList.size();
	}

	public Object getItem(int position) {
		return mMemberList.get(position);
	}

	public long getItemId(int position) {
		return position;
	}
	
	public View getView(int position, View convertView, ViewGroup parent) {
		
		final FriendsChatRoom mRowItem = mMemberList.get(position);
		LayoutInflater inflate = LayoutInflater.from(mContext);
		View mCurrentView = convertView;
		
		mCurrentView = inflate.inflate(mLayout, parent, false);
		
		ImageView imgView = (ImageView) mCurrentView.findViewById(R.id.chatRoomImage);
		
		TextView nameView  = (TextView)mCurrentView.findViewById(R.id.chatRoomName);
		TextView numberView = (TextView)mCurrentView.findViewById(R.id.chatRoomNumber);
		TextView countView = (TextView)mCurrentView.findViewById(R.id.chatRoomCount);
		
		if(mRowItem.getImage()!=null)
			imgView.setImageBitmap(mRowItem.getImage());
		
		nameView.setText(mRowItem.getTargetname());
		numberView.setText(mRowItem.getTargetnumber());
		countView.setText(mRowItem.getCountmessage());
		
		return mCurrentView;
	}
}
